package it.unical.canonaco.rende.igpe.game.cbv.datastructure;

import java.util.LinkedList;

/** 
 * @author Fabio Rende*/
public class Tree<T> {

    private TreeNode<T> root;

    public Tree() {
        root = new TreeNode<T>();
    }

    public TreeNode<T> getRoot() {
        return root;
    }

    public void setRoot(TreeNode<T> root) {
        this.root = root;
    }

    public boolean isEmpty() {
        return (root == null);
    }

    public void explore(TreeNode<T> root) {
        
   	 LinkedList<TreeNode<T>> queue = new LinkedList<TreeNode<T>>();
   	 int i = 1;
   	 
   	 queue.addLast(root);
   	 
   	 while(!queue.isEmpty()){
   		TreeNode<T> node = queue.remove();
   	  System.out.println("Nodo: "+i++);
   	 for(TreeNode<T> n : node.getChildren())
   	 queue.addLast(n);
   	 }
      
   }
    }